package com.xmb.common.service.impl;

import com.xmb.common.dao.XmbSpreadRewardSettingMapper;
import com.xmb.common.entity.XmbSpreadRewardSetting;
import com.xmb.common.service.SpreadRewardSettingService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by lyndon on 2019/4/10.
 */
@Service
public class SpreadRewardSettingServiceImpl implements SpreadRewardSettingService {

    @Resource
    private XmbSpreadRewardSettingMapper xmbSpreadRewardSettingMapper;

    @Override
    public int saveXmbSpreadRewardSetting(XmbSpreadRewardSetting xmbSpreadRewardSetting) {
        return xmbSpreadRewardSettingMapper.insertSelective(xmbSpreadRewardSetting);
    }

    @Override
    public int updateRewardSettingByActivityId(XmbSpreadRewardSetting xmbSpreadRewardSetting) {
        return xmbSpreadRewardSettingMapper.updateByActivityId(xmbSpreadRewardSetting);
    }

    @Override
    public int deleteRewardSettingByActivityIds(List<Long> activityIds) {
        return xmbSpreadRewardSettingMapper.deleteXmbSpreadRewardSetting(activityIds);
    }

    @Override
    public XmbSpreadRewardSetting findByActivityIdAndPath(Long activityId, String path) {
        XmbSpreadRewardSetting xmbSpreadRewardSetting = new XmbSpreadRewardSetting();
        xmbSpreadRewardSetting.setActivityId(activityId);
        xmbSpreadRewardSetting.setPath(path);
        xmbSpreadRewardSetting.setIsDelete(Boolean.FALSE);
        return xmbSpreadRewardSettingMapper.findByActivityIdAndPath(xmbSpreadRewardSetting);
    }

    @Override
    public XmbSpreadRewardSetting findXmbSpreadRewardSetting(XmbSpreadRewardSetting xmbSpreadRewardSetting) {
        xmbSpreadRewardSetting.setIsDelete(Boolean.FALSE);
        return xmbSpreadRewardSettingMapper.findByActivityIdAndPath(xmbSpreadRewardSetting);
    }
}
